<%@page pageEncoding="utf-8" contentType="text/html; charset=utf-8" %>
<%@ include file="/admin/include/init_admin.jsp" %>
<%@ page import="com.joinhawaii.admin.sales.*" %>
<%

	HashList code001	= CommonUtil.getCodeList("001");	//섬코드
	HashList code002	= CommonUtil.getCodeList("002");	//호텔구분


	String s_travel_start_dt	= StringUtil.nvl(request.getParameter("s_travel_start_dt"), TODAY.substring(0,6)+"01");
	String s_travel_end_dt		= StringUtil.nvl(request.getParameter("s_travel_end_dt"), TODAY);
	String s_customer_name		= StringUtil.toHan(request.getParameter("s_customer_name"));


	HashMap infos = new HashMap();
	infos.put("travel_start_dt",	s_travel_start_dt);
	infos.put("travel_end_dt",	s_travel_end_dt);
	infos.put("customer_name", s_customer_name);

	SalesDAO dao 	= new SalesDAO();
	HashList list 	= dao.selectSalesList(infos);

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<title>조인하와이</title>
	<%@ include file="/admin/include/cssnjs.jsp"  %>
	<script type="text/javascript">
	$(document).ready(function() {
		$('#s_name').focus().select();
		$('#s_travel_start_dt').mask('9999.99.99').datepicker();
		$('#s_travel_end_dt').mask('9999.99.99').datepicker();
	});


	function fnSave() {
		if (confirm("저장하시겠습니까?")) {
			$('#saveForm').attr('action', './salesListSave.do');
			$('#saveForm').submit();
		}
	}


	</script>
</head>
<body>
<div id="wrap">
	<div id="top">
		<%@ include file="/admin/include/top.jsp" %>
	</div>
	<div id="page">
		<div id="menu">
			<%@ include file="/admin/include/leftMenu.jsp" %>
		</div>
		<div id="contents">
			<div class="menu_title">
				<h1>매출관리</h1>
				<p>관리자 > 견적관리 > <b>매출관리</b></p>
			</div>
			<div class="clear line_01"></div>

			<form name="searchForm" id="searchForm" method="post" action="./salesList.jsp">

			<table cellpadding="0" cellspacing="0" class="table_01 mt15">
			<colgroup>
				<col width="100px" />
				<col width="220px" />
				<col width="100px" />
				<col  />
			</colgroup>
			<tr>
			    <th><p>출발일</p></th>
			    <td>
					<input type="text" name="s_travel_start_dt" id="s_travel_start_dt" value="<%=s_travel_start_dt %>" class="w80 c"/>
					~ <input type="text" name="s_travel_end_dt" id="s_travel_end_dt" value="<%=s_travel_end_dt %>" class="w80 c"/>


				</td>
				<th><p>고객명</p></th>
			    <td class="brx">
					<input type="text" name="s_customer_name" id="s_customer_name" value="<%=s_customer_name %>" class="w120"/>
				</td>
			</tr>
			</table>

			<div class="mt10 mb10 r">
				<input type="image" src="/images/admin/btn_search.gif" class="button"/>
				<a href="#nohref" onclick="fnSave()"><img src="/images/admin/btn_save.gif"></a>
			</div>

			</form>

			<div class="search_result">검색결과 : <%= list.size() %>건</div>

			<form name="saveForm" id="saveForm" method="post" action="./salesListSave.do">
			<input type="hidden" name="s_travel_start_dt" value="<%= s_travel_start_dt.replace(".","") %>"/>
			<input type="hidden" name="s_travel_end_dt" value="<%= s_travel_end_dt.replace(".","") %>"/>
			<input type="hidden" name="s_customer_name" value="<%= s_customer_name %>"/>

		    <table cellpadding="0" cellspacing="0" class="table_04">
				<colgroup>
					<col width="40px"/>
					<col width="100px"/>
					<col width="80px"/>
					<col width="80px"/>
					<col width="60px"/>
					<col width="200px"/>
					<col width="40px"/>
					<col width="50px"/>
					<col width="50px"/>
					<col width="50px"/>
					<col width="70px"/>
					<col width="70px"/>
					<col />
				</colgroup>
				<thead>
					<tr>
						<th><p>No</p></th>
						<th><p>고객명</p></th>
						<th><p>출발일</p></th>
						<th><p>도착일</p></th>
						<th><p>구분</p></th>
						<th><p>상품명</p></th>
						<th><p>부서</p></th>
						<th><p>수량</p></th>
						<th><p>단가</p></th>
						<th><p>원가</p></th>
						<th><p>매출액</p></th>
						<th><p>수익</p></th>
						<th><p>비고</p></th>
					</tr>
				</thead>
				<tbody id="list">
			<%
				int qtySum = 0;
				double totalSum = 0;
				double profitSum = 0;

				for (int i = 0; i < list.size(); i++) {

					qtySum += list.getInt("product_qty", i);
					totalSum += list.getDouble("total_usd", i);
					profitSum += list.getDouble("profit_usd", i);
			%>
					<tr>
						<td class="c">
							<%= list.get("est_no", i) %>
							<input type="hidden" name="list.est_no" value="<%= list.get("est_no", i) %>"/>
							<input type="hidden" name="list.est_seq" value="<%= list.get("est_seq", i) %>"/>
							<input type="hidden" name="list.product_gubn" value="<%= list.get("product_gubn", i) %>"/>
						</td>
						<td><%= list.get("customer_name", i) %></td>
						<td class="c"><%= StringUtil.toDate(list.get("travel_start_dt", i)) %></td>
						<td class="c"><%= StringUtil.toDate(list.get("travel_end_dt", i)) %></td>
						<td class="c"><%= list.get("product_gubn_name", i) %></td>
						<td class="l"><%= list.get("product_name", i) %></td>
						<td class="c"><%= list.get("dept_code", i) %></td>
						<td class="r"><%= list.get("product_qty", i) %></td>
						<td class="r"><%= list.get("price_usd", i) %></td>
						<td class="r"><input type="text" name="list.cost_usd" value="<%= list.get("cost_usd", i) %>" class="wmax r"/></td>
						<td class="r"><%= list.get("total_usd", i) %></td>
						<td class="r"><%= list.get("profit_usd", i) %></td>
						<td class="l"><input type="text" name="list.sales_desc" value="<%= list.get("sales_desc", i) %>" class="wmax"/></td>
					</tr>
			<%	} %>
					<tr>
						<td class="sum c" colspan="7">
							합계
						</td>
						<td class="sum r"><%= qtySum %></td>
						<td class="r"></td>
						<td class="r"></td>
						<td class="sum r"><%= totalSum %></td>
						<td class="sum r"><%= profitSum %></td>
						<td class="l"></td>
					</tr>
				</tbody>
			</table>
			</form>

			<div class="paging">

			</div>
		</div>
	</div>
</div>
</body>
</html>
